<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a="http://richfaces.org/a4j"
    template="layout/template.xhtml">

<ui:define name="body">

<a:loadScript src="js/sw-util.js" />
<a:loadScript src="js/jquery.maskedinput-1.3.js" />
<a:loadScript src="js/jquery.maskedinput-1.1.4.pack.js" />

    <h:form id="ConsultaVendaForm">

        <rich:panel>
            <f:facet name="header">Consulta Venda</f:facet>

            <s:decorate id="codLoteField" template="layout/edit.xhtml">
                <ui:define name="label">Lote</ui:define>
                <h:inputText id="codLoteId" value="#{ConsultaVenda.codLote}"/>
            </s:decorate>
            
            <s:decorate id="cpfField" template="layout/edit.xhtml">
                <ui:define name="label">CPF Comprador</ui:define>
                <h:inputText id="cpfId" value="#{ConsultaVenda.cpf}">
                	<rich:jQuery selector="#cpfId" query="mask('999.999.999-99')" timing="onload"></rich:jQuery>
                </h:inputText>
            </s:decorate>
            
            <s:decorate id="cnpjField" template="layout/edit.xhtml">
                <ui:define name="label">CNPJ Comprador</ui:define>
                <h:inputText id="cnpjId" value="#{ConsultaVenda.cnpj}">
                  <rich:jQuery selector="#cnpjId" query="mask('99.999.999/9999-99')" timing="onload"></rich:jQuery>
                </h:inputText>
            </s:decorate>
            
            <s:decorate id="nomeField" template="layout/edit.xhtml">
                <ui:define name="label">Nome Comprador</ui:define>
                <h:inputText id="nomeId" value="#{ConsultaVenda.nome}" size="70"/>
            </s:decorate>

            <div style="clear:both"/>

        </rich:panel>

        <div class="actionButtons">
            <h:commandButton id="consultaVenda" value="consultaVenda"
                    action="#{ConsultaVenda.consultaVenda}"/>
        </div>
        
		<rich:panel id="painelListaVendas">
				<f:facet name="header">Vendas</f:facet>


				<div class="dialog"><h:outputText
					value="Não existe registro."
					rendered="#{empty ConsultaVenda.vendas}" />
					
					<rich:dataTable id="vendasList" value="#{ConsultaVenda.vendas}"
					var="_venda" rendered="#{not empty ConsultaVenda.vendas}" styleClass="center-text" >
					
					<h:column>
						<f:facet name="header">Data</f:facet>
                    	#{_venda.dataVenda}
					</h:column>
					
					<h:column>
						<f:facet name="header">Valor</f:facet>
                    	#{_venda.valorVenda}
					</h:column>
					
					<h:column>
						<f:facet name="header">Qt lotes</f:facet>
                    	#{_venda.lotes.size()}
					</h:column>
					
					<h:column>
						<f:facet name="header">Comprador</f:facet>
                    	#{_venda.comprador}
					</h:column>
					
					<h:column>
						<f:facet name="header">Acoes</f:facet>
						<s:link action="#{ConsultaVenda.buscaVenda()}" view="/displayVenda.xhtml" propagation="join" >Ver Detalhes
							<f:param name="idVenda" value="#{_venda.id}"/>
						</s:link>
					</h:column>
					
				</rich:dataTable></div>
				
				<div style="clear: both" />

			</rich:panel>
        
        

    </h:form>

</ui:define>

</ui:composition>
